class MyPage extends BaseList {
    constructor(orderby, flag, $pagesize, $pagination, listUrl, onLineEditUrl, checkBoxName) {
        super(orderby, flag, $pagesize, $pagination, listUrl, onLineEditUrl, checkBoxName);
    }
    GetFilter(pageIndex) {
        let item = super.GetFilter(pageIndex);
        item['TypeNameFilterValue'] = formatNullInputValue($.trim($("#TypeNameFilterValue").val()));

        return JSON.stringify(item);
    }
    FetchAll() {
        $("#TypeNameFilterValue").val("");
        this.FetchForPage(1);
    }
    EmptyTableContent() {
        $("#tabData01 tbody").empty();
    }
    SetTableContent(result) {
        $("#tabData01 tbody").empty();
        let content_01 = '';
        this.rows = result.length;  // 设置表格中checkbox的数量为表格的行数
        this.numCheckbox = result.length;  // 设置表格中checkbox的数量为表格的行数
        for (let i = 0; i < result.length; i++) {
            content_01 += '<tr>';
            content_01 += '<td style="padding-left:8px; padding-top:0px; vertical-align:baseline;"><label class="btn" for="R-' + result[i].currencyId + '"><input id="R-' + result[i].currencyId + '" name="_select_row" type="radio" _msh_text="' + result[i].currencyName + '" onclick="_Instance.OnChoice($(this));" value="' + result[i].currencyId + '"/><i></i><span></span></label></td>';
            content_01 += '<td>' + result[i].currencyNo + '</td>';
            let _tmp = '<label class="forcheck" style="top:10px; left:8px;">' +
                    '    <span></span>' +
                    '    <input type="radio" name="IsLocalCurrency" disabled="disabled" class="workload" value="' + result[i].isLocalCurrency + '" ' + (parseInt(result[i].isLocalCurrency) === 1 ? 'checked' : '') + '>' +
                    '    <div class="off-radio"></div>' +
                    '    <div class="on-radio"></div>' +
                    '</label>';
            if (parseInt(result[i].isLocalCurrency) === 1) {
                content_01 += '<td>' + _tmp + '</td>';
            } else {
                content_01 += '<td></td>';
            }
            content_01 += '<td style="text-align:center;">' + result[i].currencySymbol + '</td>';
            content_01 += '<td>' + result[i].currencyName + '</td>';
            content_01 += '</tr>';

            $("#tabData01 tbody").append(content_01);
            content_01 = '';
        }
        setOneTableRowColor("tabData01");
        this.AdjustDataTableHeight();

        $(window).resize();                     // 防止因为出现滚动条而造成画面显示问题
        $('#loading').hide();
    }
    // 选择后执行的动作
    SetChoiceData($self) {
        // 设置选择结果
        let $row = $self.parent().parent().parent();
        // 返回选择结果 0:id 1:name 2:no
        return new Array($self.val(), $self.attr("_msh_text"), $row.find("td").eq(3).text());
    }
    SortTable(orderBy) {
        this.orderby = orderBy;
        // 得到排序数据
        this.FetchForPage(1);
    }
    AdjustDataTableHeight() {
        let h = $(window).height();
        let _rc = Math.floor((h - 70) / 25);
        let _dh = _rc * 25;
        var _tah = this.rows * 25;
        _dh = (_tah >= _dh) ? _dh : _tah;

        $("#divData").css({"max-height": _dh, height: _dh});
    }
}

let _Instance = null;

//-----------------------------------------------------------------------------
// 页面初始化
//-----------------------------------------------------------------------------
function onPageReady() {
    //let flag = jQuery.url.param("flag") === undefined ? 0 : jQuery.url.param("flag");
    _Instance = new MyPage(null, 0, null, null,
            "/master/currency/fetchAll.html",
            "/master/currency/online/edit.html",
            "_select_row");

    _Instance.OnPageLoad();
}

// 画面大小或者位置移动
function onPageResize() {
    if (_Instance !== null)
        _Instance.AdjustDataTableHeight();
}